<template>
	<view class="page">
		<view class="top-card">
			<view class="title">
				皆有云矿机上线
			</view>
			<view class="text">
				优惠享不停
			</view>
			
			<view class="picker">
				<picker @change="bindPicker" :value="index" :range="array">
					<view class="uni-input">
						{{array[index]}}
						<text class="lg text-gray icon cuIcon-triangledownfill"></text>
					</view>
				</picker>
			</view>
		</view>
		
		<view class="wrapper">
			<view class="list">
				<view class="card" v-for="(i, k) in list" :key="k">
					<view class="block">
						<view class="title">
							{{i.goods_name}}
						</view>
						<button class="cu-btn round btn" @click="toCart(i.id)">购买</button>
					</view>
					<view class="block" style="font-size: 30rpx;">
						￥{{i.price}} (usdt:{{i.usdt}})
					</view>
					<image class="img" :src="i.full_thumbnail" mode="aspectFill"></image>
					<!-- <view class="block2">
						<view class="line">
							<view class="left">
								矿机算力
							</view>
							<view class="right">
								0.004629 TP/s
							</view>
						</view>
						<view class="line">
							<view class="left">
								预计日产出
							</view>
							<view class="right">
								400 CNY/天
							</view>
						</view>
						<view class="line">
							<view class="left">
								预计总产量
							</view>
							<view class="right">
								90000 CNY
							</view>
						</view>
						<view class="line">
							<view class="left">
								投资回报率
							</view>
							<view class="right">
								300%
							</view>
						</view>
					</view> -->
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				array: ['皆有云矿机'],
				index: 0,
				list: []
			};
		},
		onShow() {
			this.getList();
		},
		methods: {
			bindPicker: function(e) {
				this.index = e.target.value
			},
			getList() {
				this.$u.get('/goods/list').then(res => {
					this.list = res.data.result.goods
				})
			},
			toCart(id) {
				this.$u.post('/goods/cart/add', {
					goods_id: id,
					num: 1
				}).then(res => {
					if (res.data.success) {
						uni.navigateTo({
							url: '/pages/shop/cart'
						})
					}
				})
			}
		}
	};
</script>

<style lang="scss" scoped>
	.top-card {
		margin: 20rpx 0;
		height: 300rpx;
		background: url(../../static/images/world.png);
		background-size: cover;
		color: #fff;
		letter-spacing: 8rpx;
		box-sizing: border-box;
		display: flex;
		flex-flow: column;
		justify-content: space-around;
		align-items: center;
		padding: 30rpx 0 120rpx 0;
		position: relative;
		.title {
			font-size: 40rpx;
		}
		.text {
			font-size: 40rpx;
		}
		.picker {
			position: absolute;
			bottom: 20rpx;
			background: #fff;
			font-size: 30rpx;
			width: 80%;
			padding: 16rpx 40rpx;
			border-radius: 10rpx;
		}
		.picker .uni-input {
			color: black;
			display: flex;
			justify-content: space-between;
			align-items: center;
			position: relative;
		}
		.picker .icon {
			position: absolute;
			right: -50rpx;
			top: 50%;
			transform: translateY(-50%);
			font-size: 120rpx;
			color: #00D28B;
		}
	}

	.list .card {
		color: #fff;
		background: #121135;
		padding: 30rpx 40rpx;
		border-radius: 20rpx;
		margin-bottom: 30rpx;
		.img {
			width: 300rpx;
			height: 300rpx;
			border-radius: 10rpx;
			background-color: #fff;
			margin-top: 20rpx;
		}
	}

	.list .card .btn {
		padding: 0 50rpx;
		background: #00D28B;
		color: #fff;
	}

	.card .block {
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 36rpx;
		margin: 20rpx 0;
	}

	.card .block2 {
		margin-top: 40rpx;
	}

	.card .line {
		display: flex;
		width: 100%;
		font-size: 30rpx;
		color: #B7B7BE;
		justify-content: space-between;
		align-items: center;
		margin-top: 20rpx;
	}

	.card .line .left {
		text-align: left;
	}

	.card .line .right {
		text-align: right;
		color: #00CE89;
	}
</style>
